package com.xiaoming.project.core;

import org.assertj.core.api.Assertions;

import java.math.BigDecimal;
import java.util.Objects;

public class BigDecimalTest {

    static void zeroCompare() throws InterruptedException {
        BigDecimal bZero = BigDecimal.ZERO;
        BigDecimal zero = BigDecimal.valueOf(BigDecimal.ZERO.doubleValue());
        Thread.sleep(10000);
        System.out.println(bZero.doubleValue());
        System.out.println(zero.doubleValue());
        System.out.println(bZero.equals(zero));
        System.out.println(
                Objects.equals(zero.doubleValue(), bZero.doubleValue()));
        Assertions.assertThat(zero.doubleValue())
                  .isEqualByComparingTo(bZero.doubleValue() + 1);
    }

    static void testUpRule() {
        BigDecimal bdNum = new BigDecimal("0.18");
        System.out.println(
                BigDecimal.ONE.divide(bdNum, 0, BigDecimal.ROUND_HALF_UP)
                              .intValue());
    }

}